package com.catmiw.stock2013.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class FileDirUtil {
	/**
	 * boolean checkDir(String path) ���Ŀ¼�Ƿ���ڣ������ڣ�����
	 * @param path  Ŀ¼·��
	 * @return  true/false
	 */
	public static boolean checkDir(String path) {
		File f = new File(path);
		if (f.exists()) {
			if (f.isFile())
				return false;
		} else {
			return f.mkdirs();
		}
		return true;
	}

	public static String readFileToString(String file){
		StringBuffer buf=new StringBuffer();
		try {
			BufferedReader reader=new BufferedReader(new FileReader(file));
			String s=null;
			while ((s=reader.readLine())!=null){
				buf.append(s.trim()+"\n");
			}
			reader.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return buf.toString();
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
